package com.example.demo.niuke;

/**
 * @Description:
 * @Author: LLL
 * @Date: 2020-03-21 14:35
 **/

import java.util.Scanner;

public class Main15 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextLine()) {
            String pw = scan.nextLine();
            System.out.println(tf(pw));

        }
    }

    public static String tf(String pw) {
        if (pw.length() <= 8) {
            return ("NG");

        }
        int[] count = new int[4];

        for (int i = 0; i < pw.length() - 3; i++) {
            if (pw.substring(i + 3, pw.length()).contains(pw.substring(i, i + 3))) {
                return ("NG");
            }
        }

        for (int i = 0; i < pw.length(); i++) {

            if ('A' <= pw.charAt(i) && pw.charAt(i) <= 'Z') {
                count[0] = 1;
            }
            if ('a' <= pw.charAt(i) && pw.charAt(i) <= 'z') {
                count[1] = 1;
            }
            if ('0' <= pw.charAt(i) && pw.charAt(i) <= '9') {
                count[2] = 1;
            } else {
                count[3] = 1;
            }

        }
        if (count[0] + count[1] + count[2] + count[3] < 3) {
            return ("NG");

        }

        return ("OK");
    }
}


